package com.zpark.controller;

import com.zpark.service.IUserService;
import com.zpark.pojo.Empty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

        @Autowired
        private IUserService userService;

        @RequestMapping("/add_empty")
        public String addEmpty(Empty empty) {
            userService.addEmpty(empty);
            return "用户添加成功！";
        }


        @RequestMapping("/remove_empty/{id}")
        public String removeEmptyById(@PathVariable("id") Integer id) {
            userService.removeEmptyById(id);
            return "删除用户成功！";
        }


        @RequestMapping("/change_empty")
        public String changeEmptyById(Empty empty) {
            userService.changeEmptyById(empty);
            return "修改用户成功！";
        }


        @RequestMapping("/find_all_empty")
        public List<Empty> findAllEmpty(){
            return userService.findAllEmpty();
        }


        @RequestMapping("/findByName_empty/{username}")
        public List<Empty> findByName(@PathVariable("username") String username) {
            return userService.findByName(username);
        }
}
